<script type="text/javascript" src="/kaijiangjs/parse-calc-count.js"></script>;
<?php
/*function demo() {  
    $error = error_get_last();  
        var_dump($error);  

}  
register_shutdown_function("demo");*/
/*var fun = '<?=$rows[$i]['betInfo']?>';
				var actionData = '<?=$rows[$i]['actionData']?>';
				var opencode = '<?=$opencode?>';
				var count=<?=$rows[$i]['betInfo']?>('<?=$rows[$i]['actionData']?>','<?=$opencode?>');
				var count=pk10gy('冠亚大','3,7,9,1,10,8,6,2,4,5');*/
$lastNo=$this->getGameLastNo(51);
$zddata = $this->getGameZdData(51,$lastNo['actionNo']);
$opencode =$zddata?$zddata:randKeys(10);
$sql="select * from {$this->prename}bets where type=51 and actionNo=? and isDelete=0 and lotteryNo=''";
$rows=$this->getRows($sql, '201706230339');
$LiRunLv=$this->getValue("select value from {$this->prename}params where name =?",'LiRunLv');

function js($rows,$opencode,$LiRunLv){
	
	$zjCount=$bjAmount=$zjAmount=0;	
	if($rows!=null){
		for($i=0;$i<count($rows);$i++){
			//$zjCount=$rows[$i]['betInfo']($rows[$i]['actionData'],$opencode,$rows[$i]['Groupname']);	
			$zjCount="<script type='text/javascript'>".$rows[$i]['betInfo']."('".$rows[$i]['actionData']."','".$opencode."');</script>";
			$bjAmount+=$rows[$i]['money'];				
			$zjAmount+=$rows[$i]['money']*$rows[$i]['odds']*$zjCount;
		}
	}
	$bili=$zjAmount/$bjAmount;
	$gailv=$LiRunLv/100;
	if($gailv<0){
		return false;
	}else if($bili>$gailv){
		return true;
	}else{
		return false;
	}
}
$flag=js($rows,$opencode,$LiRunLv);
while($flag==true){
	var_dump("one");
	$opencode =$zddata?$zddata:randKeys(10);
	$flag=js($rows,$opencode,$LiRunLv);
}

header('Content-type: application/xml');
echo'<?xml version="1.0" encoding="utf-8"?>';
echo '<xml><row expect="'.$lastNo['actionNo'].'" opencode="'.$opencode.'" opentime="'.$lastNo['actionTime'].'"/></xml>';

/* 生成随机数 */
function randKeys($len){
    $array=array("1","2","3","4","5","6","7","8","9","10");
    $charsLen = count($array) - 1;
    shuffle($array);
    $output = "";
    //  for ($i=0; $i<$len; $i++){

    $a= $array[mt_rand(0, $charsLen)];
    $b= $array[mt_rand(0, $charsLen)];
    while($a==$b)
    {
        $b= $array[mt_rand(0, $charsLen)];
    }
    $c=$array[mt_rand(0, $charsLen)];
    while($c==$a||$c==$b)
    {
        $c= $array[mt_rand(0, $charsLen)];
    }

    $d= $array[mt_rand(0, $charsLen)];
    while($d==$a||$d==$b||$d==$c)
    {
        $d= $array[mt_rand(0, $charsLen)];
    }
    $e= $array[mt_rand(0, $charsLen)];
    while($e==$a||$e==$b||$e==$c||$e==$d)
    {
        $e= $array[mt_rand(0, $charsLen)];
    }
    $f= $array[mt_rand(0, $charsLen)];
    while($f==$a||$f==$b||$f==$c||$f==$d||$f==$e)
    {
        $f= $array[mt_rand(0, $charsLen)];
    }
    $g= $array[mt_rand(0, $charsLen)];
    while($g==$a||$g==$b||$g==$c||$g==$d||$g==$e||$g==$f)
    {
        $g= $array[mt_rand(0, $charsLen)];
    }
    $h= $array[mt_rand(0, $charsLen)];
    while($h==$a||$h==$b||$h==$c||$h==$d||$h==$e||$h==$f||$h==$g)
    {
        $h= $array[mt_rand(0, $charsLen)];
    }
    $i= $array[mt_rand(0, $charsLen)];
    while($i==$a||$i==$b||$i==$c||$i==$d||$i==$e||$i==$f||$i==$g||$i==$h)
    {
        $i= $array[mt_rand(0, $charsLen)];
    }
    $j= $array[mt_rand(0, $charsLen)];
    while($j==$a||$j==$b||$j==$c||$j==$d||$j==$e||$j==$f||$j==$g||$j==$h||$j==$i)
    {
        $j= $array[mt_rand(0, $charsLen)];
    }
    //$output .= $array[mt_rand(0, $charsLen)].",";
    //  }
    return $outpuet=$a.','.$b.','.$c.','.$d.','.$e.','.$f.','.$g.','.$h.','.$i.','.$j;
    // return rtrim($output, ',');
}
?>